package nahuel.games.carracer;

import android.graphics.Bitmap;
import android.graphics.Canvas;

public class Boton {
	public static final int ARRIBA = 2;
	public static final int ABAJO = 3;
	public static final int IZQ = 0;
	public static final int DER = 1;
	
	private static final float VELOCIDAD = 1;
	private static final float GIRO = 1;

	private Bitmap bmp;
    private int x = 0;
    private int y = 0;
    private float xVel = 0;
    private float yVel = 0;
    @SuppressWarnings("unused")
	private int direccion;
    private int width;
    private int height;

	public Boton(Bitmap bmp, int direccion, int anchoPant, int altoPant) {
		this.bmp = bmp;
		this.width = bmp.getWidth();
		this.height = bmp.getHeight();
		this.direccion = direccion;
		switch(direccion){
		case Boton.ARRIBA:
			yVel = VELOCIDAD;
			this.x = anchoPant / 2 - width / 2;
			this.y = altoPant - height * 2;
			break;
		case Boton.ABAJO:
			yVel = -VELOCIDAD;
			this.x = anchoPant / 2 - width / 2;
			this.y = altoPant - height;
			break;
		case Boton.IZQ:
			xVel = -GIRO;
			this.x = 10;
			this.y = altoPant - height;
			break;
		case Boton.DER:
			xVel = GIRO;
			this.x = anchoPant - width - 10;
			this.y = altoPant - height;
			break;
		}
	}

	public float getXVel() {
		return xVel;
	}

	public float getYVel() {
		return yVel;
	}

	public void draw(Canvas canvas) {
		canvas.drawBitmap(bmp, x, y, null);
	}
	
	public boolean fuePresionado(float x2, float y2){
		return x2 > x && x2 < x + width && y2 > y && y2 < y + height;
	}
	
}
